{extend name="layout" /}
{block name="body"}
<div class="row">
    <div class="col-lg-12">
        <div class="card">
            <div class="card-body">
                <div class="form-group">
                    <input type="hidden" id="id" value="{$data.id}">
                    <label for="name">商品名称</label>
                    <input type="text" class="form-control" id="name" value="{$data.name}"
                        placeholder="请输入商品名称">
                </div>
                <div class="form-group">
                    <label for="detail">商品详情</label>
                    <textarea class="form-control" id="detail" rows="3"
                        placeholder="商品详情">{$data["detail"]}</textarea>
                </div>
                <div class="form-group">
                    <label for="price">商品价格</label>
                    <input type="number" class="form-control" id="price" value="{$data.price}" placeholder="请输入商品价格">
                </div>
                <div class="form-group">
                    <label for="vipdate">会员天数</label>
                    <input type="number" class="form-control" id="vipdate" value="{$data.vipdate}" placeholder="请输入会员天数">
					<!-- <input class="form-control" type="text" data-provide="datetimepicker" id="vipdate"
					placeholder="请选择具体时间" value="{$data.vipdate}" data-side-by-side="true" 
					data-format="YYYY-MM-DD HH:mm:ss" /> -->
				</div>
                <button type="buttons" onclick="updateshop()" class="btn btn-w-sm btn-primary mb-2">提交</button>
                <button type="button" class="btn btn-default mb-2" onclick="javascript:history.back(-1);return false;">返
                    回
                </button>
            </div>
        </div>
    </div>
</div>
{/block}
{block name="js"}
<script>
    function changenone(obj) {
        if (obj.options[obj.selectedIndex].value == 1) {
            document.getElementById("select_else").style.display = "";
        } else {
            document.getElementById("select_else").style.display = "none";
        }
    }

    function updateshop() {
        var l = $('body').lyearloading({
            opacity: 0.2,
            spinnerSize: 'lg',
            spinnerText: '后台处理中，请稍后...',
            textColorClass: 'text-info',
            spinnerColorClass: 'text-info'
        });
        var id = $.trim($("#id").val());
        var name = $.trim($("#name").val());
        var detail = $.trim($("#detail").val());
		var price = $.trim($("#price").val());
		var vipdate = $.trim($("#vipdate").val());
        $.ajax({
            type: "POST",
            url: "{:url('shop/edit')}",
            data: {
				id:id,
				name:name,
				detail:detail,
				price:price,
				vipdate:vipdate
			},
            dataType: "json",
            success: function (data) {
                setTimeout(function () {
                    l.destroy();
                }, 1e3)
                if (data.code == 1) {
                    notify.success(data.msg);
                } else {
                    notify.error(data.msg);
                }
            },
            error: function () {
                l.destroy();
                notify.error("系统错误");
            }
        })
    }

</script>
{/block}